package com.toune.villager.fragment

import com.toune.dltools.adapter.DLAdapterTool
import com.toune.villager.R
import com.toune.villager.model.HomeFragmentModel
import com.toune.dltools.ui.DLBaseFragment
import com.toune.villager.adapter.MyFamilyAdapter
import com.toune.villager.bean.MyFamilyBean
import kotlinx.android.synthetic.main.fragment_mine.*


class MineFragment : DLBaseFragment<HomeFragmentModel>() {
    override val layout: Int
        get() = R.layout.fragment_mine

    val familyBeans = ArrayList<MyFamilyBean>()
    var myFamilyAdapter: MyFamilyAdapter? = null
    override fun lazyInit() {
        val myFamilyBean = MyFamilyBean()
        myFamilyBean.name = "80分"
        myFamilyBean.phone = "13333333333"
        myFamilyBean.identity="户主"
        familyBeans.add(myFamilyBean)
        myFamilyBean.name = "90分"
        myFamilyBean.phone = "15555555555"
        myFamilyBean.identity="妻子"
        familyBeans.add(myFamilyBean)
        myFamilyBean.name = "100分"
        myFamilyBean.phone = "16666666666"
        myFamilyBean.identity="长子"
        familyBeans.add(myFamilyBean)
        myFamilyBean.name = "110分"
        myFamilyBean.phone = "18888888888"
        myFamilyBean.identity="长女"
        familyBeans.add(myFamilyBean)
        setFamilyAdapter()
    }

    private fun setFamilyAdapter() {
        if (myFamilyAdapter == null) {
            myFamilyAdapter = MyFamilyAdapter(R.layout.adapter_my_family, familyBeans)
            val dlAdapterTool =
                DLAdapterTool<MyFamilyBean>(requireContext(), familyRcy, myFamilyAdapter!!)
            myFamilyAdapter!!.setOnItemClickListener { adapter, view, position ->

            }
        } else {
            myFamilyAdapter!!.notifyDataSetChanged()
        }
    }
}